package com.joyer.web;

import com.alibaba.fastjson.JSON;
import com.joyer.exception.BusinessException;
import com.joyer.service.BlogProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author wzy
 * @date 2018/4/11
 */
@Controller
@RequestMapping(value = "/f")
public class HelloController {
    private final Logger logger = LoggerFactory.getLogger(HelloController.class);
    @Autowired
    BlogProperties blogProperties;
    @Value("${com.joyer.blog.desc}")
    private String desc;
    @RequestMapping(value = "hello",method = RequestMethod.GET)
    @ResponseBody
    public String hello(HttpServletRequest request) throws Exception{
        logger.debug("request param: " + JSON.toJSONString(request.getParameterMap()));
//        return desc;
        throw new BusinessException("发生错误");
    }
    @RequestMapping("/login")
    public String login() {
        return "login";
    }

}
